package com.liuceng.zen.service;

import java.util.List;
import java.util.Map;

import com.liuceng.zen.pojo.form.ForntCampaignForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.liuceng.zen.mapper.FrontCampaignMapper;
import com.liuceng.zen.pojo.domain.FrontCampaign;
import org.springframework.amqp.core.AmqpTemplate;

@Service
public class FrontCampaignService extends BaseService<FrontCampaign> {

  @Autowired
  FrontCampaignMapper frontCampaignMapper;
  @Autowired
  private AmqpTemplate adLifeTemplate;



  public List<FrontCampaign> findByMemberId(Map<String, Object> map) {
    return frontCampaignMapper.findByMemberId(map);
  }


  public void processAdGroupPutLife(FrontCampaign campaign) {
    if (ForntCampaignForm.START == campaign.getCampaignStatus()) {
      adLifeTemplate.convertAndSend(BaseService.DIRECT_EXCHANGE, "hlt.ad_life_quene",
          campaign.getMemberId() + ":" + campaign.getId() + ":*:set-zen");
    } else {
      // 清空redis里面广告生存时间
      adLifeTemplate.convertAndSend(BaseService.DIRECT_EXCHANGE, "hlt.ad_life_quene",
          campaign.getMemberId() + ":" + campaign.getId() + ":*:clear-zen");
    }
  }


}
